Developer Documentation

QuickTime 4 API Documentation

QuickTime Movie File Format Specification, May 1996

| Previous | Chapter contents | Chapter top | Next |

Time-to-Sample Atoms

Time-to-sample atoms store duration information for a media's samples, providing a mapping from a time in the media to the corresponding data sample. The time-to-sample atom has an atom type of 'stts' .

You can determine the appropriate sample for any time in a media by examining the time-to-sample atom table, which is contained in a time-to-sample atom.

Figure 0-31 shows the layout of a time-to-sample atom.

Figure 31 The layout of a time-to-sample atom

The time-to-sample atom contains the following data elements.

Size
A 32-bit integer that specifies the number of bytes in this time-to-sample atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'stts' .
Version
A 1-byte specification of the version of this time-to-sample atom.
Flags
A 3-byte space for time-to-sample flags. Set this field to 0.
Number of entries
A 32-bit integer containing the number of entries in the time-to-sample table.
Time-to-sample table
A table that defines the duration of each sample in the media. Each table entry contains a count field and a duration field. The structure of a time-to-sample table is shown in Figure 0-32 .

Figure 32 The layout of a time-to-sample table

You define a time-to-sample table by specifying these entries:

Sample count
A 32-bit integer that specifies the number of consecutive samples that have the same duration.
Sample duration
A 32-bit integer that specifies the duration of each sample.

Entries in the table describe samples according to their order in the media and their duration. If consecutive samples have the same duration, a single table entry may be used to define more than one sample. In these cases, the count field indicates the number of consecutive samples that have the same duration. For example, if a video media has a constant frame rate, this table would have one entry and the count would be equal to the number of samples.

Figure 0-33 presents an example of a time-to-sample table that is based on the chunked media data shown in Figure 0-28 . That data stream contains a total of nine samples that correspond in count and duration to the entries in the table shown here. Even though samples 4, 5, and 6 are in the same chunk, sample 4 has a duration of 3, and samples 5 and 6 have a duration of 2.

Figure 33 An example of a time-to-sample table


© 1997 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Next |